﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace IMCOM.Imagiality.ImageProcessing.Canvas2D.ROI
{
    public abstract class RectangleROIHandle
    {
        protected Rectangle rectangle;

        // size of the handle in pixels
        public const int HANDLE_SIZE = 8;

        public RectangleROIHandle(Point center)
        {
            rectangle = new Rectangle(center.X - HANDLE_SIZE / 2, center.Y - HANDLE_SIZE / 2, HANDLE_SIZE, HANDLE_SIZE);
        }

        public abstract Rectangle Resize(Point mouseDelta, Rectangle rectangle);
        public abstract Cursor GetCursor();

        public void Display(Graphics graphics)
        {
            Brush handleBrush = new SolidBrush(Color.White);
            Pen handlePen = new Pen(Color.Black);

            graphics.FillRectangle(handleBrush, rectangle);
            graphics.DrawRectangle(handlePen, rectangle);
        }

        public bool IsWithinHandle(Point point)
        {
            return rectangle.Contains(point);
        }
    }
}
